package com.ykh.mybbsdemo.config;

import com.ykh.mybbsdemo.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * Description: 统一异常处理
 * User: YKH
 * Date: 2023-05-01
 * Time: 18:47
 */
@ControllerAdvice
@ResponseBody
public class ExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public Object exceptionError(Exception e){
        //得到抛出异常后, 进行封装后返回数据.
        return Result.fail(-999, "系统错误");
    }
}
